# -*- coding: utf-8 -*-
"""
Created on Mon Sep 13 19:05:53 2021

@author: 10194
"""

import itertools
res = []
for i in itertools.product([1,2,3,4], repeat = 2):
    res.append(i)
#i[0]项的1,2,3,4，对应名次
#i[1]项1,2,3,4,对应红，紫，蓝，绿色的车
for i in res:
    if i[0] == 1 or i[0] == 4:#mike不是第一也不是第四
        continue
    for j in res:
        if j[0] == 1 or j[0] == 4 or j[1] != 2:#Ellie不是第一也不是第四,Ellie骑紫色的车
            continue
        for k in res:
            if k[1] == 4:#Rohan没骑绿色的车
                continue
            for m in res:
                if m[1] == 3:#Fatma不骑蓝色车
                    continue
                l1 = [i[0], j[0], k[0], m[0]]#名次
                l2 = [i[1], j[1], k[1], m[1]]#颜色
                if len(set(l1)) != 4 or len(set(l2)) != 4:#去除有重复名次和重复颜色的四元组
                    continue
                flag = 0
                for o in range(4):
                    if l2[o] == 4 and l1[o] > j[0]:#绿色车人领先紫色车人
                        flag = 1
                        break
                    if l2[o] == 3 and l1[o] > m[0]:#蓝色车人领先Fatma
                        flag = 1
                        break
                if flag == 1:
                    continue
                print(i, j, k, m)#输出对应四元组
                
    
